Add sort option -prefix-then-key-order-reverse
authorJustin Burkett <justin@burkett.cc>
Sat, 29 Oct 2016 12:34:42 +0000 (08:34 -0400)
committerJustin Burkett <justin@burkett.cc>
Sat, 29 Oct 2016 12:35:54 +0000 (08:35 -0400)
Fixes #145

which-key.el

index c17a1c7a3eb5b78fbb77a44a5aaba71a30f249f3..70372675ce92925b39f43ef924aa9f06970599ae 100644 (file)
@@ -1176,6 +1176,16 @@ coming before a prefix. Within these categories order using
         (and (not apref?) bpref?)
       (which-key-key-order acons bcons))))
 
+(defun which-key-prefix-then-key-order-reverse (acons bcons)
+  "Order first by whether A and/or B is a prefix with prefix
+coming before a prefix. Within these categories order using
+`which-key-key-order'."
+  (let ((apref? (which-key--group-p (cdr acons)))
+        (bpref? (which-key--group-p (cdr bcons))))
+    (if (not (eq apref? bpref?))
+        (and apref? (not bpref?))
+      (which-key-key-order acons bcons))))
+
 (defun which-key-local-then-key-order (acons bcons)
   "Order first by whether A and/or B is a local binding with
 local bindings coming first. Within these categories order using